<template>
    <div>
<h2>登录</h2>
<table class="table ">
    <tbody>
        <tr>
            <td>用户名</td>
            <td>
                <input  type="text"  v-model="model.UserName"> 
            </td>
        </tr>


        <tr>
            <td>密码</td>
            <td>
                <input  type="password" v-model="model.UserPwd" > 
            </td>
        </tr>



        <tr>
            <td></td>
            <td>
                <input  type="button" value="登录" class="btn btn-success" @click="ok"> 
            </td>
        </tr>
    </tbody>
</table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref,reactive } from 'vue';
import { useRoute,useRouter } from 'vue-router';
const route=useRoute();
const router=useRouter();



let model=reactive({
 "UserName": '',
"UserPwd": '',
})


const ok=()=>{

axios({
url:'https://localhost:7289/api/User/Login',
method:'post',
data:model,
})

.then((res)=>{
console.log(res);
if(res.data==0){
alert('账号不存在');
return;
}
else if(res.data==-1){
alert('密码错误');
return;
}
else{
    alert('登录成功');
}


})

.catch((ree)=>{
console.log(ree);
})




}


</script>

<style scoped>

</style>